﻿using System;
using System.Windows.Forms;

namespace EasyIot.WinApp
{
    public partial class SystemForm : Form, IBaseRedirectEvent
    {
        public event EventHandler<BaseRedirectArgs> eventShowForm;

        public SystemForm()
        {
            InitializeComponent();
            this.TopLevel = false;
        }

        public virtual void ShowForm(RedirectType eType = RedirectType.Redirect_Next, object oParam = null)
        {
            if (!this.Visible)
            {
                this.Show();
            }
            this.BringToFront();
        }

        public virtual void HideForm()
        {

        }

        public virtual void OnEventShowForm(FormCase eFormCase, RedirectType eRedirectType = RedirectType.Redirect_Next, object oParam = null)
        {
            EventHandler<BaseRedirectArgs> handler = this.eventShowForm;
            if (handler != null)
            {
                this.HideForm();// 关闭现有窗体
                handler(this, new BaseRedirectArgs(eFormCase, eRedirectType, oParam));// 打开指定窗体
            }
        }
    }
}
